#include <FastLED.h>

#include<Arduino.h>

#include<FastLED.h>

#define NUM_LEDS 256//灯珠数
#define LED_TYPE WS2812B//led类型
#define WS2812B_PIN 18//输入口
#define COLOR_ORDER GRB

uint8_t max_bright=10;//最大亮度
uint8_t colorIndex;//变化灯的变量

CRGB leds[NUM_LEDS];//创建led灯带

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);//启动
  delay(500);

  LEDS.addLeds<LED_TYPE,WS2812B_PIN,COLOR_ORDER>(leds,NUM_LEDS);//初始化灯带

  FastLED.setBrightness(max_bright);
}
void lun()//轮廓
{
    fill_gradient_RGB(leds,50,CRGB::BlueViolet   ,61,CRGB::BlueViolet   );
  fill_gradient_RGB(leds,226,CRGB::BlueViolet   ,237,CRGB::BlueViolet   );
  for(int i=65,j=78;i<=209;i+=16,j+=16)
  {
    leds[i]=CRGB::BlueViolet ;
    leds[j]=CRGB::BlueViolet ;
  }
  leds[3]=CRGB::BlueViolet ;
  leds[12]=CRGB::BlueViolet ;
  leds[20]=CRGB::BlueViolet ;
  leds[27]=CRGB::BlueViolet ;
  leds[37]=CRGB::BlueViolet ;
  leds[42]=CRGB::BlueViolet ;
}
//字模
void zi1()
{
  lun();
  leds[84]=CRGB::BlueViolet ;//眼睛
  leds[91]=CRGB::BlueViolet ;
  leds[101]=CRGB::BlueViolet ;
  leds[106]=CRGB::BlueViolet ;
  leds[118]=CRGB::BlueViolet ;
  leds[121]=CRGB::BlueViolet ;
  leds[133]=CRGB::BlueViolet ;
  leds[138]=CRGB::BlueViolet ;
  leds[148]=CRGB::BlueViolet ;
  leds[155]=CRGB::BlueViolet ;
  
  leds[181]=CRGB::BlueViolet ;//嘴上
  leds[183]=CRGB::BlueViolet ;
  leds[184]=CRGB::BlueViolet ;
  leds[186]=CRGB::BlueViolet ;
 
  leds[198]=CRGB::BlueViolet ;//嘴下
  leds[201]=CRGB::BlueViolet ;
  
  FastLED.show();
  delay(1500);
}

void zi2()
{
  lun();
  for(int i=0;i<4;i++)//眼睛
  {
    int j=i*16;
    leds[100+j]=CRGB::BlueViolet ;
    leds[101+j]=CRGB::BlueViolet ;
    leds[106+j]=CRGB::BlueViolet ;
    leds[107+j]=CRGB::BlueViolet ;
  }
  for(int i=0;i<4;i++)//嘴
  {
    leds[198+i]=CRGB::BlueViolet ;
  }
  FastLED.show();
  delay(1000);
}



void mie()//表情变化过渡
{
  for(int i=0;i<256;i++)
  {
    leds[i]=CRGB::Black;
  }

  lun();
}

void fla()
{
  int i=0;
  while(i<200)
  {
    colorIndex++; 
    fill_palette (leds,    NUM_LEDS,   colorIndex,          5,          OceanColors_p      ,  50,   LINEARBLEND );
    FastLED.show();
    delay(25);
    i++;
  }
   
}

void mie2()
{
  for(int i=0;i<256;i++)
  {
    leds[i]=CRGB::Black;
  }
}

void fan(int num[4][256])
{
	for (int q = 0; q < 4; q++)
	{
		int i = 0, j = 15, ret = 2;
		while (j < 256)
		{
      int sum=(i+j)/2;
			for (int o = i, p = j; p > sum; o++, p--)
			{
				if (ret % 2 == 0)
				{
					int temp = num[q][o];
					num[q][o] = num[q][p];
					num[q][p] = temp;
				}

			}
			i += 16;
			j += 16;
			ret++;
		}
	}
}


void show1(int num[4][256])
{
  fan(num);
  for(int i=0;i<4;i++)
  {
    for(int j=0;j<256;j++)
    {
      if(num[i][j]==1)
      {
        leds[j]=CRGB::BlueViolet ;
      }
      else
      {
        leds[j]=CRGB::Black ;
      }
    }
    FastLED.show();
    delay(1000);
    mie2();
  }
}

void loop() {
  // put your main code here, to run repeatedly:
int XXX[4][256]={
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1,0,0,0,0,1,1,1,1,0,1,1,0,0,0,
0,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